<?php
class ModelProductModel extends abstract_product_model implements interface_product_model {

    public function getProduct($product_id){
        if($product = $this->getPlugin("product")->getProduct($product_id)){
            return $product->getData();
        }
        return false;
    }

    public function getProducts($data = array()){
        $list = $this->getPlugin("products")->getProducts($data);

        $result = array();
        foreach($list as $product){
            $result[$product->get_id()] = $product->getData();
        }
        return $result;
    }

    public function getProductSpecials($data = array()){
        $list = $this->getPlugin("specials")->getProductSpecials($data);

        $result = array();
        foreach($list as $product){
            $result[$product->get_id()] = $product->getData();
        }
        return $result;
    }


    public function getCategories($product_id) {
        return $this->getPlugin("categories")->getCategories($product_id);
    }	

    public function getPopularProducts($limit){

    }
    public function getProductLayoutId($product_id){
        return $this->getPlugin("layout")->getProductLayoutId($product_id);
    }
    public function getProductImages($product_id){
        return $this->getPlugin("images")->getProductImages($product_id);
    }
    public function getProductRelated($product_id){
        $list = $this->getPlugin("related")->getProductRelated($product_id);

        $result = array();
        foreach($list as $product){
            $result[$product->get_id()] = $product->getData();
        }
        return $result;

    }
    public function getProductDiscounts($product_id){
        return $this->getPlugin("discounts")->getProductDiscounts($product_id);
    }
    public function getProductOptions($product_id){
        return $this->getPlugin("attributes")->getProductAttributes($product_id);
    }
    public function getProductAttributes($product_id){
        return $this->getPlugin("attributes")->getProductAttributes($product_id);
    }
    public function updateViewed($product_id){
        return $this->getPlugin("update")->viewed($product_id);
    }
    public function getTotalProducts($data = array()){
        return $this->getPlugin("total")->getTotal($data);
    }
    public function getTotalProductSpecials(){

    }
    public function getBestSellerProducts($limit){

        $list = $this->getPlugin("bestseller")->getBestSellerProducts($limit);
        $result = array();
        foreach($list as $product){
            $result[$product->get_id()] = $product->getData();
        }

        return $result;

    }
    public function getLatestProducts($limit){

        $list = $this->getPlugin("latest")->getLatestProducts($limit);
        $result = array();
        foreach($list as $product){
            $result[$product->get_id()] = $product->getData();
        }

        return $result;
    }
}
